package tree;

import java.util.Comparator;

/**
 * @author Europa
 * @create 2020-05-18 13:33
 */
public abstract class BaseTree<T> {


    Comparator<? super T> compare;

    int compare(T lhs, T rhs) {
        if (this.compare != null) {
            return compare.compare(lhs, rhs);
        } else {
            return ((Comparable<T>) lhs).compareTo(rhs);
        }
    }

    /**
     * 置空root节点
     */
    public abstract void makeEmpty();

    /**
     * 判断root节点是否为空
     *
     * @return root节点为null返回true, 反之false
     */
    public abstract boolean isEmpty();

    /**
     * 判断目标是否存在
     *
     * @param target 查询目标
     * @return 存在返回true, 反之false
     */
    public abstract boolean contains(T target);

    public abstract T findMin();

    public abstract T findMax();

    public abstract void insert(T target);

    public abstract void remove(T target);
}
